import axios from 'axios'
import * as actionTypes from './actionTypes'

export const logoOut = () => ({
    type: actionTypes.LOGO_OUT,
    value: false
})

const changeLogin = () => ({
    type: actionTypes.CHANGE_LOGIN,
    value: true
})

export const login = (account, password) => {
    return (dispatch) => {
        axios.get(`/api/login.json?account=${account}&password=${password}`).then((res)=>{
            // console.log(res.data)
            const result = res.data.data;
            if(result){
                dispatch(changeLogin())
            }else {
                alert('登录失败')
            }
        })
    }
}